const mongoose = require('mongoose');
const { ObjectId } = mongoose.Schema;

module.exports = {
  versionId: {
    type: ObjectId,
  },
  // 入口函数id
  functionId: {
    type: ObjectId,
  },
  testcaseId: {
    type: ObjectId,
    index: true,
  },
  // 调用链前置函数id数组,从入口函数开始直到fromFuncId
  preFuncIds: {
    type: [ObjectId],
  },
  fromFuncId: ObjectId,
  fromFuncMangledId: String,
  fromFuncFileId: ObjectId,
  callFuncs: [{
    // 被调函数id, 未定义函数为null
    toFuncId: ObjectId,
    // 被调函数文件路径
    toFuncFilePath: {
      type: String,
    },
    // 被调函数mangled id
    toFuncMangledId: {
      type: String,
    },
    callexprs: [{
      // 调用次数
      times: {
        type: Number,
      },
      // 调用者函数内的callexpr id
      callexprId: {
        type: String,
      },
    }],
  }],
};
